#include "String.h"

using namespace lzc;
using std::cout;
using std::endl;
using std::cin;

void test1() {
	string s1("string hehe");
	string s2;

	s1.insert(0, 't');
	s1.insert(10, 'i');
	s1.insert(13, 'i');

	s2.push_back('x');
	s2.push_back('x');
	s2.push_back('x');
	s2.push_back('x');

	s2.insert(4, "hehe");
	s2.insert(0, "hehe");

	s1.insert(0, "");
	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;
}

void test2() {
	string s1("hello world");
	cout << s1.c_str() << endl;
	s1 += " lala";
	s1 += '3';
	s1 += '3';
	s1 += '3';
	cout << s1.c_str() << endl;
	s1.erase(0, 5);
	cout << s1.c_str() << endl;
	s1.erase(9, -2);
	cout << s1.c_str() << endl;
}

void test3() {
	string s("https://legacy.cplusplus.com/reference/string");
	size_t pos = 0;
	pos = s.find('/', pos);
	while (pos != string::npos) {
		cout << s[pos + 1] << endl;
		pos = s.find('/', pos + 1);
	}
	pos = s.rfind('h');
	cout << pos << endl;
}
void test4() {
	string s("hello world");
	string ret = s.substr();
	cout << ret.c_str() << endl;
}

void test5() {
	try
	{
		std::string s("012345678");
		//std::string ret = s.substr(9);
		//cout << ret << endl;
		//ret = s.substr(10);
		//cout << ret << endl;

		//size_t pos = s.find("abcde", 100);

		s.erase(9, 1000);
		cout << s << endl;
	}
	catch (const std::exception& e)
	{
		cout << e.what() << endl;
	}
}

void test6() {
	string s("0123456");
	s.erase(7, 100);
	cout << s.c_str() << endl;

	s.erase(7, 0);
	cout << s.c_str() << endl;
}

void test7() {
	string s("hello world"), t;
	cout << s << endl;
	cin >> s >> t;
	cout << s << t;
}

void test8() {
	std::string s("hello");
	cout << s.size() << endl;
	s += '\0';
	s += '\0';
	s += '\0';
	s += '\0';
	s += "haha";
	cout << s.size() << endl;
	cout << s << endl;
	string s1("hello");
	cout << s1.size() << endl;
	s1 += '\0';
	s1 += '\0';
	s1 += '\0';
	s1 += '\0';
	s1 += "haha";
	cout << s1.size() << endl;
	cout << s1 << endl;
}

void test9() {
	std::string s("01234\0");
	s.append(0, '5');
	cout << s << endl;
}
int main() {
	test9();
	printf("%d\n", 1 << 31);
	return 0;
}